from pathlib import Path

# 创建列表储存文件名
file_names = ['cats.txt','dogs.txt']
# 遍历文件名并阅读文件内容
for file_name in file_names:
    path = Path(file_name)
    try:
        contents = path.read_text()
    except FileNotFoundError:
        print("抱歉，我没有找到文件")
    else:
        print(f"\nReading file: {file_name}")
        print(contents)
